/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package controladores;

import controladores.exceptions.NonexistentEntityException;
import entidades.miembros.Socio;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.RollbackException;
import javax.persistence.criteria.CriteriaQuery;

/**
 *
 * @author Felipe
 */
public class SocioJpaController extends BaseControlador
{
    public SocioJpaController ()
    {
        super ();
    }
    
    public SocioJpaController(EntityManager em)
    {
        super(em);
    }
 
    public List<Socio> buscarSocios (String cadena)
    {
        Query query = em.createNamedQuery("buscarPorNombreApellido");
        query.setParameter(1, cadena);
        return query.getResultList();
    }
    
    public List<Socio> buscarTodos ()
    {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Socio.class));
        Query q = em.createQuery(cq);

        return q.getResultList();
    }
}
